<?php

namespace App\Services\Home;



use App\Models\Rentalhouse;

class RentalhouseService
{
    protected $regionService;
    protected $propertyService;

    public function __construct(RegionService $regionService, PropertyService $propertyService)
    {
        $this->regionService = $regionService;
        $this->propertyService = $propertyService;
    }

    /**
     * @param $id
     * @return mixed
     * 详情
     */
    public function getDetailById($id)
    {
        return Rentalhouse::with(['community'])->findOrFail($id);
    }

    public function data($request)
    {
        $res = Rentalhouse::with('attribute')
            ->valid($request->input('sort'))
            ->filter($request->all())
            ->paginateFilter($request->input('pagesize',10));

        $data = [
            'code' => 0,
            'msg' => '正在请求中...',
            'total' => $res['total'],
            'data' => $res
        ];
        return response()->json($data);
    }
}